using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnManager : MonoBehaviour
{
    public GameObject obstaclePrefab;
    private PlayerController playerController;
    //private Vector3 spawnPos = new Vector3(25, 0, 0);
    //private float startDelay;
    //private float repeatRate;
    // Start is called before the first frame update
    void Start()
    {
        playerController = GameObject.Find("Player").GetComponent<PlayerController>();

        InvokeRepeating("SpawnObstacle", 1f, 2f);//startDelay, repeatRate);
        //Instantiate(obstaclePrefab, spawnPos, obstaclePrefab.transform.rotation);
    }

    // Update is called once per frame
    void Update()
    {
        if (playerController.gameOver == true)
        {
            CancelInvoke("SpawnObstacle");
            //Instantiate(obstaclePrefab, spawnPos, obstaclePrefab.transform.rotation);
        }
    }
    public void SpawnObstacle()
    {
       
            Instantiate(obstaclePrefab);
        
    }
}
